﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;

namespace BabyLearnEnglish_srcum_demo
{
    public partial class Form1 : Form
    {
        public static CommonLibrary culInfoMgr;
        public Form1()
        {
            InitializeComponent();
            culInfoMgr = new CommonLibrary();
            culInfoMgr.changeCultureInfo("vi-VN");
        }

        public static int level = 0;
        public static string uername = "unname";
        public static int score = 0;
        //public static int currentQ = 0;
        public static List<question> listCurQ = new List<question>();
        public static List<question> listQ = new List<question>();
        public static int[] arrOld = new int[100];

        private void btnChoi_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < (level + 1) * 2; i++)
            {
                Random random = new Random();
                int randomNumber = random.Next(0, listQ.Count);
                int pos = Array.IndexOf(arrOld, randomNumber);
                if (pos == -1)
                {
                    listCurQ.Add(listQ[randomNumber]);
                    arrOld[i] = randomNumber;
                }
                else
                    i--;
            }
            frmChoi frm = new frmChoi();
            frm.ShowDialog();

            level = 0;
            uername = "unname";
            score = 0;

            listCurQ = new List<question>();
            arrOld = new int[100];
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            level = 0;
            uername = "unname";
            score = 0;

            listCurQ = new List<question>();
            listQ = new List<question>();
            arrOld = new int[100];
            Form1.listQ = new question().getList();
            //--------------------------------------------------
            SoundPlayer soud = new SoundPlayer("../../data/audio/Song.wav");
            soud.Play();          
        }

        private void btnChonCapDo_Click(object sender, EventArgs e)
        {
            frmChonCapDo frm = new frmChonCapDo();
            frm.ShowDialog();
        }

        private void bntBangXepHang_Click(object sender, EventArgs e)
        {
            frmXemDiem frm = new frmXemDiem();
            frm.ShowDialog();
        }

        private void btnTroGiup_Click(object sender, EventArgs e)
        {
            frmHuongDan frm = new frmHuongDan();
            frm.ShowDialog();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void cboLang_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
